package com.controller;

import com.Result.ResultData;
import com.entity.Person;
import com.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Objects;

@Controller
public class PersonController {
    @Autowired
    private PersonService personService;

    @RequestMapping("/register.do")
    @ResponseBody
    public ResultData register(@RequestParam(name="user_name",required=true) String user_name,
                               @RequestParam(name="user_password",required=true) String user_password,
                               @RequestParam(name="user_sex",required=true) int user_sex,
                               @RequestParam(name="user_age",required=true) int user_age,
                               @RequestParam(name="user_pro",required=true) String user_pro,
                               @RequestParam(name="user_hobby",required=true) String user_hobby) {
        ResultData resultData = personService.Register(user_name,user_password,user_sex,
                user_age,user_pro,user_hobby);
        return resultData;
    }
    @RequestMapping("/login.do")
    @ResponseBody
    public ResultData login(@RequestParam(name="user_name",required=true) String user_name,
                               @RequestParam(name="user_password",required=true) String user_password) {
        ResultData resultData = personService.Login(user_name,user_password);
        return resultData;
    }
}
